<?
include('print_checks.php');
//include('functions.php');
$arr=get_upcomming_payments($pdiff,'array');
$account = array(
                'name1'=>'Snapy Communications Inc.',
                'name2'=>'',
                'address1'=>'1500 University Drive, ste 117',
                'address2'=>'',
                'city'=>'Coral Springs',
                'state'=>'FL',
                'zip'=>'33071',
                'country'=>'',
                'holder_logo'=>'',
                'bank_name'=>'Bank of America',
                'bank_address'=>'1000 North Federal Highway',
                'bank_address2'=>'',
                'bank_city'=>'Boca Raton',
                'bank_state'=>'FL',
                'bank_zip'=>'32432',
                'bank_country'=>'',
                'bank_logo'=>'',
                'routing_number'=>'&063000047&',
                'account_number'=>"003679595765/",
        );
$d2 = date('F Y',mktime ( 0, 0, 0, date('m')-$pdiff, 1, date('Y') ));//$pdiff
//print_r($arr);
$check_num=1832;
//echo count($arr);exit;
foreach($arr as $k => $v){
	if($v['first_name']!='unknown' and $v['first_name']!='Kalin' and $v['first_name']!='Nikolay')
		$checks[]=$v;
}
foreach($checks as $k=>$v){
	if($v[payment_method]=='check'){
		$checks[$k][check_number] = $check_num++;
	}else unset($arr[$k]);
}
foreach($arr as $aaa){
/*
echo "insert into payments (payout_account_id,date,payment_type,reseller_id,first_name,last_name,email,phone,address1,address2,city,state,zip,country,swift_code,bank_name,bank_address,account_number,routing_number,account_holder,payment_method,tax_id,status,amount,check_number,paypal_email)

values('2',now(),'$aaa[payment_type]', '$aaa[reseller_id]', '$aaa[first_name]', '$aaa[last_name]', '$aaa[email]', '$aaa[phone]', '$aaa[address1]', '$aaa[address2]', '$aaa[city]', '$aaa[state]', '$aaa[zip]', '$aaa[country]', '$aaa[swift_code]', '$aaa[bank_name]', '$aaa[bank_address]', '$aaa[account_number]', '$aaa[routing_number]', '$aaa[account_holder]', '$aaa[payment_method]', '$aaa[tax_id]', '$aaa[status]', '$aaa[amount]','$aaa[check_number]','$aaa[paypal_email]');
<br><br>";
*/
}
function print_envelopes($array_clients, $from){
    $size=12;
	$pdf = pdf_new();
	pdf_open_file($pdf,"");
	foreach($array_clients as $v){
		pdf_begin_page($pdf, 625, 315);
		pdf_set_parameter($pdf,'FontOutline','Arial=C:\Program Files\Apache Group\Apache2\htdocs\www\rp2\www\resellers\admin\payouts\fonts\arial.ttf');
		$font = pdf_findfont($pdf, 'Arial','host', 0);
	        pdf_setfont($pdf, $font, $size);
	        pdf_show_xy($pdf, $from, 25, 290);
			pdf_show_xy($pdf, $v['first_name']." ".$v['last_name'], 340, $h=130);
			pdf_setfont($pdf, $font, $size);
			pdf_show_xy($pdf, $v['address1'], 340, $h=$h-12);
			if($check['address2']!=''){
			pdf_show_xy($pdf, $v['address2'], 340, $h=$h-12);
			}
			pdf_show_xy($pdf, $v['city'].", ".$v['state']." ".$v['zip'], 340, $h=$h-12);
			pdf_show_xy($pdf, $v['country'], 340, $h=$h-12);
			pdf_end_page($pdf);
			}
	pdf_close($pdf);
	$data = pdf_get_buffer($pdf);
	header("Content-type: application/pdf");
	header("Content-disposition: inline; filename=checks.pdf");
	header("Content-length: " . strlen($data));
	echo $data;
}
generate_pdf($account, $checks);
//print_envelopes ($checks,'resellerspanel.com');
